home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-01-30 | 8.7 KB | 259 lines | [TEXT/MPS ] |
-
- ;=============================================================================================
- GblA &qMacApp
- GblA &qDebug
- GblA &qNames
-
- If &TYPE('qMacApp') = 'UNDEFINED' Then
- &qMacApp SetA 0 ; we assume we’re MacAppless if qMacApp isn’t defined
- Else
- &qMacApp SetA qMacApp
- EndIf
-
- If &TYPE('qDebug') = 'UNDEFINED' Then
- &qDebug SetA 0 ; default to qDebug off
- Else
- &qDebug SetA qDebug
- EndIf
-
- If &TYPE('qNames') = 'UNDEFINED' Then
- &qNames SetA &qDebug
- Else
- &qNames SetA qNames
- EndIf
-
- * ================================================
- * ------ CONSTANTS DEFINITIONS SECTION --------
- * ================================================
-
- rAboutAlert EQU 257 ; about alert
- kUseCreatorString EQU -1
- kUseRealAppName EQU -2
-
-
- * ================================================
- * -------- MACRO DEFINITIONS SECTION ----------
- * ================================================
-
- * ------------- GENERATE A PASCAL “CASE” OR “IF” SEQUENCE -------------
- * The following macro is used to generate a branch based on an index value
- * in a D-register with a value from 0 to N. The branch is through a table
- * of relative addresses also generated by this macro. The macro is called
- * in one of two forms as follows:
-
- * {Form #1} Case# (Dreg,Default),case0,case1,...caseN
- * {Form #2} Case#.<size> (Dreg,IF),(cst0,case0),...,(cstN,caseN)
-
- * In Form #1, the “Default” specifies a label for any omitted case labels not
- * specified explicitly. The “case0”, “case1”,...“caseN” are case labels
- * identifying the various cases to be processed. A case label may be omitted,
- * in which case the “Default” is used. The “Default” may also be omitted, but
- * in that case all case labels must be specified. If there are fewer case labels
- * than there are cases, but there are N possible values for the case index, the
- * proper number of trailing commas must be supplied to generate the defaults.
-
- * In Form #2, the default is specified as the word “IF”. In this form the macro
- * generates a set of compares (CMPI’s) and branches (BEQ) for each specified
- * case (there is no implicit default). Each case is a constant/label pair.
- * The constant is compared (CMPI.W) and an branch is done (BEQ) to the case if
- * the Dreg equals the constant. A size may be specified for all the branches
- * as a <size> attribute to the Case# call itself. This must either be an “S”
- * or “W” to generate BEQ.S’s or BEQ.W’s. The default is for “S”.
-
- MACRO
- Case#.&Size &IdxDef
- PRINT Push,NoMDir ; only list generated code
- LCLA &i ; index to macro parameters
- LCLA &n ; total number of macro parameters
- LCLC &Dreg,&Def ; the Dreg and Default parameters
- LCLC &sz ; the <size> value
-
- &Dreg SETC &IdxDef[1] ; pick off 1st opnd of sublist
- &Def SETC &IdxDef[2] ; pick off 2nd opnd of sublist
- &n SETA &Nbr(&Syslist) ; done for efficiency
- &i SETA 2 ; cases start at 2nd parameter
-
- IF &UpCase(&Def) <> 'IF' THEN
-
- .* Create the jump table and the index value
- * -----------------------------------------------
- ADD &Dreg,&Dreg
- MOVE Case&SysNdx(&Dreg),&Dreg
- JMP Case&SysNdx(&Dreg)
-
- Case&SysNdx
- WHILE &i <= &n DO ; process each case label
- IF &SysList[&i] <> '' THEN
- DC.W &SysList[&i]-Case&SysNdx
- ELSE
- DC.W &Def-Case&SysNdx
- ENDIF
- &i: SETA &i+1 ; count off parameter
- ENDWHILE
- ELSE ; process (Cst,lbl) pairs
-
- .* Create a series of CMPI and BEQ instructions
- * -----------------------------------------------
- &Sz: SETC &Default(&Size, 'S') ; setup size attribute
- WHILE &i <= &n DO ; process each (Cst,lbl) pair
- CMPI #&SysList[&i,1],&Dreg
- BEQ.&Sz &SysList[&i,2]
- &i: SETA &i+1 ; count off parameter
- ENDWHILE
- ENDIF
-
- PRINT Pop ; restore original print status
- ENDM
-
-
- * ------------- GENERATE DEBUGGER SYMBOL INFORMATION -------------
- * This Macro will generate information for the debugger to read and display
- * as its module name. This aids in debugging Asm code while looking at it
- * in the debugger. This macro can only work if called at the end of stack
- * frame. The appearance of the Macro statement in the source code must occur
- * immediately after the final “JMP (A0)” or “RTS” instruction following the UNLINK.
- * Spaces may be included in the name, but no quotes are allowed.
-
- * {Form #1} DbgInfo.Old Name ModName
- * {Form #2} DbgInfo.New Name Really Long Module Name For MacsBug 6.0
- * {Form #3} DgbInfo Name Same as DbgInfo.New
-
- * There are now two naming conventions used in MacsBug, Form #1 is the older MacsBug,
- * or TMON, and Form #2 is the newer MacsBug 6.0. The older method would only
- * allow for a fixed length of eight characters. If a shorter name is passed to
- * this Macro, it will extend the length to 8 chars with trailing spaces.
- * MacsBug 6.0 will now allow for a variable length C type string. This Macro will
- * create the proper DC statements and takes into account word alignment issues.
-
-
- MACRO
- DbgInfo.&Opt &ModName# ; the name to be used in the Debugger
- PRINT Push,NoMDir ; Only list generated code
- GBLA &qNames ; determines whether we want to do any of this
- LCLC &DbgName# ; name to generate for MacsBug
- LCLC &DbgTemp ; temporary name variable
- LCLC &New ; variable used to test old vs. new
- LCLC &S ; variable used to save PRINT state
-
- IF &qNames THEN ; do we want debugging info?
- IF &ModName# ≠ '' THEN ; did we get a module name?
- &New: SETC &UpCase(&Opt) ; make option all upper case
- IF (&New = '') THEN ; if user didn’t specify...
- &New: SETC 'NEW' ; then default to new style
- ENDIF
- IF (&New = 'NEW') THEN ; do we want new style?
-
- .* Create the new MacsBug naming convention
- * -----------------------------------------------
- &DbgTemp: SETC &ModName# ; generate new type symbols
- IF &Len(&ModName#) < 32 THEN ; if module name < 32 chars
- IF &Len(&ModName#) // 2 = 0 THEN ; add space if even so that...
- &DbgTemp: SETC &Concat(&ModName#,' ') ; string length plus length byte...
- ENDIF ; will align to word boundary
- &DbgName#: SETC &Concat(&Chr($80 + &Len(&ModName#)), &DbgTemp)
- ELSE ; Length > 32 characters
- IF &Len(&ModName#) // 2 = 1 THEN ; add space if length is odd
- &DbgTemp: SETC &Concat(&ModName#,' ')
- ENDIF
- &DbgName#: SETC &Concat(&Chr($80), &Chr(&Len(&ModName#)), &DbgTemp)
- ENDIF
- ELSE ; make it the older style
-
- .* Create the older MacsBug naming convention
- * -----------------------------------------------
- ; IF &Len(&ModName#) < 8 THEN ; if module name < 8 chars
- &DbgName#: SETC &Concat(&ModName#,' ') ; add at least 7 spaces
- &DbgName#: SETC &Concat(&Chr($80 + &ORD(&SubStr(&DbgName#,1,1))), &SubStr(&DbgName#,2,7))
- ; ELSE ; there are at least 8 chars
- ; &DbgName#: SETC &Concat(&Chr($80 + &ORD(&SubStr(&ModName#,1,1))), &SubStr(&ModName#,2,7))
- ; ENDIF
- ENDIF
-
- .* Create the DC.B with the debugger name, and include the NULs if new MacsBug option
- * -----------------------------------------------
- &S: SETC &Setting('STRING') ; preserve STRING status
- IF &S ≠ 'ASIS' THEN ; only change it if not already ASIS
- STRING ASIS
- DC.B '&DbgName#'
- IF (&New = 'NEW') THEN
- DC.W 0 ; fake literal size for new MacsBug
- ENDIF
- STRING &S
- ELSE
- DC.B '&DbgName#'
- IF (&New = 'NEW') THEN
- DC.W 0 ; fake literal size for new MacsBug
- ENDIF
- ENDIF ; IF &S ≠ 'ASIS' THEN
- ENDIF ; IF &ModName# ≠ '' THEN
- ENDIF ; IF &qNames THEN
-
- PRINT Pop ; restore original print status
- ENDM
-
-
-
- * ================================================
- * ---------------- RECORD TYPES ----------------
- * ================================================
- * This section is declaring record structures. These records are
- * templates. No data is allocated at this point. These are just
- * structures, similar to Pascal TYPEs. They simply generate a list
- * of equate offsets. Since none of these types are defined already
- * in the MPW AIncludes, we’ll need to define them.
-
- * ------------- MOUSE POINT TYPE -------------
-
- Point RECORD 0
- v DS.W 1
- h DS.W 1
- ORG v
- vh DS.W h
- ENDR
-
- * ------------- RECTANGLE TYPE -------------
-
- Rect RECORD 0
- Top DS.W 1
- Left DS.W 1
- Bottom DS.W 1
- Right DS.W 1
- ORG Top
- TopLeft DS.L 1
- BotRight DS.L 1
- ENDR
-
- * ------------- BITMAP TYPE -------------
-
- BitMap RECORD 0
- baseAddr DS.L 1
- rowBytes DS.W 1
- bounds DS.L Rect
- ENDR
-
- * ------------- EVENT RECORD TYPE -------------
-
- EventRecord RECORD 0
- What DS.W 1
- Message DS.L 1
- When DS.L 1
- Where DS.L Point
- Modify DS.W 1
- ENDR
-
- * ------------- THE QUICKDRAW WORLD -------------
-
- QuickGlobals RECORD 0,DECREMENT
- GrafPort DS.L 1
- White DS.B 8
- Black DS.B 8
- Gray DS.B 8
- LtGray DS.B 8
- DkGray DS.B 8
- Arrow DS.B cursRec
- ScreenBits DS.B BitMap
- RandSeed DS.L 1
- ORG -GrafSize
- ENDR
-
-